package dome3;

/**
 * Created with IntelliJ IDEA.
 * Description:  Clone接口代码测试
 * User: 王圆豪
 * Date: 2024-06-28
 * Time: 14:18
 */
public class Person implements Cloneable{
    private String name;
    private int age;
    private Deposit deposit;

    public Person(String name, int age, Deposit deposit) {
        this.name = name;
        this.age = age;
        this.deposit = deposit;
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Deposit getDeposit() {
        return deposit;
    }

    public void setDeposit(Deposit deposit) {
        this.deposit = deposit;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", deposit=" + deposit +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();
        tmp.deposit = (Deposit) this.deposit.clone();
        return tmp;
    }
}
